﻿using System;
using System.Linq;
using FX.CC.Andon.Entity.ReportManage;
using FX.CC.Andon.Service.ReportManage;
using FX.CC.Andon.Utility.Json;

namespace FX.CC.Andon.Business.ReportManage
{
    /// <summary>
    /// 异常柏拉图业务层
    /// </summary>
    public class ExceptionPlatoBusiness
    {
        private readonly ExceptionPlatoService _dal=new ExceptionPlatoService();

        public string GetExceptionPlatoList(AbnormalQcEntity qcmodel)
        {
            var list = _dal.GetExceptionPlatoList(qcmodel);
            var stepCount = 0;
            decimal total = list.Sum(p => p.Number);
            foreach (var i in list)
            {
                stepCount += i.Number;
                i.Count = stepCount;
                i.Rate = Math.Round(i.Count / total * 100, 2);
            }
            return JsonHelper.Encode(list);
        }
    }
}
